home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MacApp / MacApp 3.0a2 / CPlusIncludes / TextEdit.h < prev    next >
Text File  |  1991-05-01  |  13KB  |  332 lines

  1. /************************************************************
  2.  
  3. Created: Sunday, January 6, 1991 at 10:11 PM
  4.     TextEdit.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.         Copyright Apple Computer, Inc.    1985-1990
  9.         All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13.  
  14. #ifndef __TEXTEDIT__
  15. #define __TEXTEDIT__
  16.  
  17. #ifndef __GEOMETRY__
  18. #include <Geometry.h>
  19. #endif
  20.  
  21. #ifndef __QUICKDRAW__
  22. #include <Quickdraw.h>
  23. #endif
  24.  
  25.  
  26. enum {
  27.  
  28.  
  29. /* Justification styles */
  30.     teJustLeft = 0,
  31.     teJustCenter = 1,
  32.     teJustRight = -1,
  33.     teForceLeft = -2,
  34.  
  35. /* new names for the Justification styles */
  36.     teFlushDefault = 0,                                 /*flush according to the line direction */
  37.     teCenter = 1,                                       /*center justify */
  38.     teFlushRight = -1,                                  /*flush right for all scripts */
  39.     teFlushLeft = -2,                                   /*flush left for all scripts */
  40.  
  41. /* Set/Replace style modes */
  42.     fontBit = 0,                                        /*set font*/
  43.     faceBit = 1,                                        /*set face*/
  44.     sizeBit = 2,                                        /*set size*/
  45.     clrBit = 3,                                         /*set color*/
  46.     addSizeBit = 4,                                     /*add size mode*/
  47.     toglBit = 5,                                        /*set faces in toggle mode*/
  48.  
  49. /* TESetStyle/TEContinuousStyle modes */
  50.     doFont = 1,                                         /* set font (family) number*/
  51.     doFace = 2,                                         /*set character style*/
  52.     doSize = 4,                                         /*set type size*/
  53.     doColor = 8,                                        /*set color*/
  54.     doAll = 15,                                         /*set all attributes*/
  55.     addSize = 16                                        /*adjust type size*/
  56. };
  57. enum {
  58.     doToggle = 32,                                      /*toggle mode for TESetStyle & TEContinuousStyle*/
  59.  
  60. /* offsets into TEDispatchRec */
  61.     EOLHook = 0,                                        /*[ProcPtr] TEEOLHook*/
  62.     DRAWHook = 4,                                       /*[ProcPtr] TEWidthHook*/
  63.     WIDTHHook = 8,                                      /*[ProcPtr] TEDrawHook*/
  64.     HITTESTHook = 12,                                   /*[ProcPtr] TEHitTestHook*/
  65.     nWIDTHHook = 24,                                    /*[ProcPtr] nTEWidthHook*/
  66.     TextWidthHook = 28,                                 /*[ProcPtr] TETextWidthHook*/
  67.  
  68. /* selectors for TECustomHook */
  69.     intEOLHook = 0,                                     /*TEIntHook value*/
  70.     intDrawHook = 1,                                    /*TEIntHook value*/
  71.     intWidthHook = 2,                                   /*TEIntHook value*/
  72.     intHitTestHook = 3,                                 /*TEIntHook value*/
  73.     intNWidthHook = 6,                                  /*TEIntHook value for new version of WidthHook*/
  74.     intTextWidthHook = 7,                               /*TEIntHook value for new TextWidthHook*/
  75.  
  76. /* feature or bit definitions for TEFeatureFlag */
  77.     teFAutoScr = 0,                                     /*00000001b*/
  78.     teFTextBuffering = 1,                               /*00000010b*/
  79.     teFOutlineHilite = 2,                               /*00000100b*/
  80.     teFInlineInput = 3,                                 /*00001000b*/
  81.     teFUseTextServices = 4,                             /*00010000b*/
  82.  
  83. /* action for the new "bit (un)set" interface, TEFeatureFlag */
  84.     TEBitClear = 0,
  85.     TEBitSet = 1                                        /*set the selector bit*/
  86. };
  87. enum {
  88.     TEBitTest = -1,                                     /*no change; just return the current setting*/
  89.  
  90. /*constants for identifying the routine that called FindWord */
  91.     teWordSelect = 4,                                   /*clickExpand to select word*/
  92.     teWordDrag = 8,                                     /*clickExpand to drag new word*/
  93.     teFromFind = 12,                                    /*FindLine called it ($0C)*/
  94.     teFromRecal = 16                                    /*RecalLines called it ($10)*/
  95. };
  96.  
  97. typedef pascal Boolean (*WordBreakProcPtr)(Ptr text, short charPos);
  98. typedef pascal Boolean (*ClikLoopProcPtr)(void);
  99.  
  100. struct TERec {
  101.     Rect destRect;
  102.     Rect viewRect;
  103.     Rect selRect;
  104.     short lineHeight;
  105.     short fontAscent;
  106.     Point selPoint;
  107.     short selStart;
  108.     short selEnd;
  109.     short active;
  110.     WordBreakProcPtr wordBreak;
  111.     ClikLoopProcPtr clikLoop;
  112.     long clickTime;
  113.     short clickLoc;
  114.     long caretTime;
  115.     short caretState;
  116.     short just;
  117.     short teLength;
  118.     Handle hText;
  119.     short recalBack;
  120.     short recalLines;
  121.     short clikStuff;
  122.     short crOnly;
  123.     short txFont;
  124.     Style txFace;                                       /*txFace is unpacked byte*/
  125.     char filler;
  126.     short txMode;
  127.     short txSize;
  128.     GrafPtr inPort;
  129.     ProcPtr highHook;
  130.     ProcPtr caretHook;
  131.     short nLines;
  132.     short lineStarts[16001];
  133. };
  134.  
  135. typedef TERec *TEPtr, **TEHandle;
  136.  
  137. typedef char Chars[32001];
  138. typedef char *CharsPtr,**CharsHandle;
  139.  
  140. struct StyleRun {
  141.     short startChar;                                    /*starting character position*/
  142.     short styleIndex;                                   /*index in style table*/
  143. };
  144.  
  145. typedef struct StyleRun StyleRun;
  146.  
  147. struct STElement {
  148.     short stCount;                                      /*number of runs in this style*/
  149.     short stHeight;                                     /*line height*/
  150.     short stAscent;                                     /*font ascent*/
  151.     short stFont;                                       /*font (family) number*/
  152.     Style stFace;                                       /*character Style*/
  153.     char filler;                                        /*stFace is unpacked byte*/
  154.     short stSize;                                       /*size in points*/
  155.     RGBColor stColor;                                   /*absolute (RGB) color*/
  156. };
  157.  
  158. typedef struct STElement STElement;
  159.  
  160. typedef STElement TEStyleTable[1777], *STPtr, **STHandle;
  161.  
  162. struct LHElement {
  163.     short lhHeight;                                     /*maximum height in line*/
  164.     short lhAscent;                                     /*maximum ascent in line*/
  165. };
  166.  
  167. typedef struct LHElement LHElement;
  168.  
  169. typedef LHElement LHTable[8001], *LHPtr, **LHHandle;    /* ARRAY [0..8000] OF LHElement */
  170.  
  171. struct ScrpSTElement {
  172.     long scrpStartChar;                                 /*starting character position*/
  173.     short scrpHeight;                                   /*starting character position*/
  174.     short scrpAscent;
  175.     short scrpFont;
  176.     Style scrpFace;                                     /*unpacked byte*/
  177.     char filler;                                        /*scrpFace is unpacked byte*/
  178.     short scrpSize;
  179.     RGBColor scrpColor;
  180. };
  181.  
  182. typedef struct ScrpSTElement ScrpSTElement;
  183.  
  184. typedef ScrpSTElement ScrpSTTable[1601];                /* ARRAY [0..1600] OF ScrpSTElement */
  185.  
  186. struct StScrpRec {
  187.     short scrpNStyles;                                  /*number of styles in scrap*/
  188.     ScrpSTTable scrpStyleTab;                           /*table of styles for scrap*/
  189. };
  190.  
  191. typedef struct StScrpRec StScrpRec;
  192. typedef StScrpRec *StScrpPtr, **StScrpHandle;
  193.  
  194. struct NullStRec {
  195.     long teReserved;                                    /*reserved for future expansion*/
  196.     StScrpHandle nullScrap;                             /*handle to scrap style table*/
  197. };
  198.  
  199. typedef struct NullStRec NullStRec;
  200. typedef NullStRec *NullStPtr, **NullStHandle;
  201.  
  202. struct TEStyleRec {
  203.     short nRuns;                                        /*number of style runs*/
  204.     short nStyles;                                      /*size of style table*/
  205.     STHandle styleTab;                                  /*handle to style table*/
  206.     LHHandle lhTab;                                     /*handle to line-height table*/
  207.     long teRefCon;                                      /*reserved for application use*/
  208.     NullStHandle nullStyle;                             /*Handle to style set at null selection*/
  209.     StyleRun runs[8001];                                /*ARRAY [0..8000] OF StyleRun*/
  210. };
  211.  
  212. typedef struct TEStyleRec TEStyleRec;
  213. typedef TEStyleRec *TEStylePtr, **TEStyleHandle;
  214.  
  215. struct TextStyle {
  216.     short tsFont;                                       /*font (family) number*/
  217.     Style tsFace;                                       /*character Style*/
  218.     char filler;                                        /*tsFace is unpacked byte*/
  219.     short tsSize;                                       /*size in point*/
  220.     RGBColor tsColor;                                   /*absolute (RGB) color*/
  221. };
  222.  
  223. typedef struct TextStyle TextStyle;
  224. typedef TextStyle *TextStylePtr, **TextStyleHandle;
  225.  
  226.  
  227. typedef short TEIntHook;
  228.  
  229. #ifdef __cplusplus
  230. extern "C" {
  231. #endif
  232. pascal void TEInit(void)
  233.     = 0xA9CC; 
  234. pascal TEHandle TENew(const Rect& destRect,const Rect& viewRect)
  235.     = 0xA9D2; 
  236. pascal void TEDispose(TEHandle hTE)
  237.     = 0xA9CD; 
  238. pascal void TESetText(const void *text,long length,TEHandle hTE)
  239.     = 0xA9CF; 
  240. pascal CharsHandle TEGetText(TEHandle hTE)
  241.     = 0xA9CB; 
  242. pascal void TEIdle(TEHandle hTE)
  243.     = 0xA9DA; 
  244. pascal void TESetSelect(long selStart,long selEnd,TEHandle hTE)
  245.     = 0xA9D1; 
  246. pascal void TEActivate(TEHandle hTE)
  247.     = 0xA9D8; 
  248. pascal void TEDeactivate(TEHandle hTE)
  249.     = 0xA9D9; 
  250. pascal void TEKey(short key,TEHandle hTE)
  251.     = 0xA9DC; 
  252. pascal void TECut(TEHandle hTE)
  253.     = 0xA9D6; 
  254. pascal void TECopy(TEHandle hTE)
  255.     = 0xA9D5; 
  256. pascal void TEPaste(TEHandle hTE)
  257.     = 0xA9DB; 
  258. pascal void TEDelete(TEHandle hTE)
  259.     = 0xA9D7; 
  260. pascal void TEInsert(const void *text,long length,TEHandle hTE)
  261.     = 0xA9DE; 
  262. pascal void TESetJust(short just,TEHandle hTE)
  263.     = 0xA9DF; 
  264. pascal void TEUpdate(const Rect& rUpdate,TEHandle hTE)
  265.     = 0xA9D3; 
  266. pascal void TextBox(const void *text,long length,const Rect& box,short just)
  267.     = 0xA9CE; 
  268. pascal void TEScroll(short dh,short dv,TEHandle hTE)
  269.     = 0xA9DD; 
  270. pascal void TESelView(TEHandle hTE)
  271.     = 0xA811; 
  272. pascal void TEPinScroll(short dh,short dv,TEHandle hTE)
  273.     = 0xA812; 
  274. pascal void TEAutoView(Boolean fAuto,TEHandle hTE)
  275.     = 0xA813; 
  276. #define TEScrapHandle() (* (Handle*) 0xAB4)
  277. pascal void TECalText(TEHandle hTE)
  278.     = 0xA9D0; 
  279. pascal short TEGetOffset(Point pt,TEHandle hTE)
  280.     = 0xA83C; 
  281. pascal Point TEGetPoint(short offset,TEHandle hTE)
  282.     = {0x3F3C,0x0008,0xA83D}; 
  283. pascal void TEClick(Point pt,Boolean fExtend,TEHandle h)
  284.     = 0xA9D4; 
  285. pascal TEHandle TEStylNew(const Rect& destRect,const Rect& viewRect)
  286.     = 0xA83E; 
  287. pascal void SetStylHandle(TEStyleHandle theHandle,TEHandle hTE)
  288.     = {0x3F3C,0x0005,0xA83D}; 
  289. pascal TEStyleHandle GetStylHandle(TEHandle hTE)
  290.     = {0x3F3C,0x0004,0xA83D}; 
  291. pascal void TEGetStyle(short offset,TextStyle& theStyle,short& lineHeight,
  292.     short& fontAscent,TEHandle hTE)
  293.     = {0x3F3C,0x0003,0xA83D}; 
  294. pascal void TEStylPaste(TEHandle hTE)
  295.     = {0x3F3C,0x0000,0xA83D}; 
  296. pascal void TESetStyle(short mode,const TextStyle& newStyle,Boolean redraw,
  297.     TEHandle hTE)
  298.     = {0x3F3C,0x0001,0xA83D}; 
  299. pascal void TEReplaceStyle(short mode,const TextStyle& oldStyle,const TextStyle& newStyle,
  300.     Boolean redraw,TEHandle hTE)
  301.     = {0x3F3C,0x0002,0xA83D}; 
  302. pascal StScrpHandle GetStylScrap(TEHandle hTE)
  303.     = {0x3F3C,0x0006,0xA83D}; 
  304. pascal void TEStylInsert(const void *text,long length,StScrpHandle hST,
  305.     TEHandle hTE)
  306.     = {0x3F3C,0x0007,0xA83D}; 
  307. pascal long TEGetHeight(long endLine,long startLine,TEHandle hTE)
  308.     = {0x3F3C,0x0009,0xA83D}; 
  309. pascal Boolean TEContinuousStyle(short& mode,TextStyle& aStyle,TEHandle hTE)
  310.     = {0x3F3C,0x000A,0xA83D}; 
  311. pascal void SetStylScrap(long rangeStart,long rangeEnd,StScrpHandle newStyles,
  312.     Boolean redraw,TEHandle hTE)
  313.     = {0x3F3C,0x000B,0xA83D}; 
  314. pascal void TECustomHook(TEIntHook which,ProcPtr& addr,TEHandle hTE)
  315.     = {0x3F3C,0x000C,0xA83D}; 
  316. pascal long TENumStyles(long rangeStart,long rangeEnd,TEHandle hTE)
  317.     = {0x3F3C,0x000D,0xA83D}; 
  318. pascal short TEFeatureFlag(short feature,short action,TEHandle hTE)
  319.     = {0x3F3C,0x000E,0xA83D}; 
  320. #define TEGetScrapLen() ((long) * (unsigned short *) 0x0AB0)
  321. pascal void TESetScrapLen(long length); 
  322. pascal OSErr TEFromScrap(void); 
  323. pascal OSErr TEToScrap(void); 
  324. pascal void SetClikLoop(ClikLoopProcPtr clikProc,TEHandle hTE); 
  325. pascal void SetWordBreak(WordBreakProcPtr wBrkProc,TEHandle hTE); 
  326. void teclick(Point *pt,Boolean fExtend,TEHandle h); 
  327. #ifdef __cplusplus
  328. }
  329. #endif
  330.  
  331. #endif
  332.